package com.ruoyi.param.service.impl;

import com.ruoyi.param.domain.TparamTp;
import com.ruoyi.param.mapper.TparamTpMapper;
import com.ruoyi.param.service.ITparamTpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ITparamTpServiceImpl implements ITparamTpService {

    @Autowired
    private TparamTpMapper tparamTpMapper;

    @Autowired
    private ThreadPoolTaskExecutor threadPoolTaskExecutor;

    @Override
    public List<TparamTp> selectTpList(TparamTp record) {
        return tparamTpMapper.selectTpList(record);
    }

    @Override
    public List<TparamTp> selectTpListByRoomIds(List<String> roomIds, Integer runType) {
        return tparamTpMapper.selectTpListByRoomIds(roomIds, runType);
    }

    @Override
    public void insertSelective(TparamTp record) {
        tparamTpMapper.insertSelective(record);
    }

    @Override
    public void deleteByRoomIds(List<String> roomIds) {
        tparamTpMapper.deleteByRoomIds(roomIds);
    }

    @Override
    public void updateByRoomIdSelective(TparamTp record) {
        threadPoolTaskExecutor.execute(() -> tparamTpMapper.updateByRoomIdSelective(record));
    }

    @Override
    public void refresh(List<TparamTp> records) {
        if (!records.isEmpty()) {
            tparamTpMapper.refresh(records);
        }
    }
}
